package com.five.wisdomClass.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.five.wisdomClass.entity.Major;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MajorMapper extends BaseMapper<Major> {

    // 获取每个专业的学生人数
    @Select("SELECT sp.major, COUNT(s.id) AS student_count FROM smartcampus.specialty sp LEFT JOIN smartcampus.studentinfo s ON s.major = sp.major GROUP BY sp.s_id, sp.major;")
    List<Major> getMajorStudents();
}
